package com.panshi.service.impl;

import com.panshi.mapper.ISlideshowMapper;
import com.panshi.pojo.Slideshow;
import com.panshi.service.ISlideshowService;
import com.panshi.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SlideshowServiceImpl implements ISlideshowService {

    @Autowired
    ISlideshowMapper iSlideshowMapper;

    @Autowired
    RedisUtil redisUtil;


    @Override
    public List<Slideshow> queryList() {
        Object slideshowList = redisUtil.lGetIndex("slideshowList", 0);
        if (slideshowList != null) {
            System.out.println("缓存数据slideshowList：" + slideshowList);
            return (List<Slideshow>) slideshowList;
        }
        return iSlideshowMapper.queryList();
    }


    @Override
    public Slideshow getSlideshowId(Integer sid) {
        return iSlideshowMapper.getSlideshowId(sid);
    }

    @Override
    public void addSlideshow(Slideshow slideshow) {
        iSlideshowMapper.addSlideshow(slideshow);
    }

    @Override
    public void updateSlideshow(Slideshow slideshow) {
        iSlideshowMapper.addSlideshow(slideshow);
    }
}
